package com.sinochem.sales.common.util;

import com.sinochem.sales.common.exception.CheckedException;
import org.springframework.util.StringUtils;

/**
 * 数据校验
 *
 * @author xuan
 * @date 2017-03-23 15:50
 */
public class AssertUtils {

    public static void isNull(Object object, String message) {
        if (null != object) {
            throw new CheckedException(message);
        }
    }

    public static void isBlank(String str, String message) {
        if (!StringUtils.isEmpty(str)) {
            throw new CheckedException(message);
        }
    }


    public static void notNull(Object object, String message) {
        if (null == object) {
            throw new CheckedException(message);
        }
    }

    public static void notBlank(String str, String message) {
        if (StringUtils.isEmpty(str)) {
            throw new CheckedException(message);
        }
    }

    public static void isTrue(boolean value, String message) {
        if (!value) {
            throw new CheckedException(message);
        }
    }

    public static void equals(String a, String b, String message) {
        if (!a.equals(b)) {
            throw new CheckedException(message);
        }
    }


}
